package cn.school.thoughtworks.section2;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class PracticeA {
    Map<String,Integer> countSameElements(List<String> collection1) {

        Map map=new HashMap();
        Object[] objects = collection1.toArray();
        for(int i=0;i<objects.length;i++){
            if(map.get(objects[i])!=null){
                Integer integer= (Integer) map.get(objects[i]);
                integer++;
                map.put(objects[i],integer);
            }else {
                map.put(objects[i], 1);
            }
        }
        return map;
    }
}